<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>扫码支付</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script src="../js/jsencrypt.min.js"></script>
    <script src="../js/jquery.params.js"></script>
    <script src="../js/qrcode.min.js"></script>
</head>
<body>

<div id="qr_code">

</div>
<input id="text" type="text" value="http://www.runoob.com" style="width:80%" /><br />
<div id="qrcode" style="width:100px; height:100px; margin-top:15px;"></div>

<script>
    $(function () {
        getData1();
        makeCode();

        $("#text").on("blur", function () {
            makeCode();
        }).
        on("keydown", function (e) {
            if (e.keyCode == 13) {
                makeCode();
            }
        });
    });

    function getData1() {
        var qr_code = $.query.get("qr_code");
        console.log(qr_code);
        document.getElementById("qr_code").innerHTML = JSON.parse(qr_code)['qr_code'];
        $("#text").val(JSON.parse(qr_code)['qr_code']);
    }

    var qrcode = new QRCode(document.getElementById("qrcode"), {
        width : 100,
        height : 100
    });

    function makeCode () {
        var elText = document.getElementById("text");

        if (!elText.value) {
            alert("Input a text");
            elText.focus();
            return;
        }
        qrcode.makeCode(elText.value);
    }



</script>
</body>
</html>